//
//  ProjectSeletedHeadView.m
//  XiaoMiao
//
//  Created by kinglian_iOS_000 on 2018/1/30.
//  Copyright © 2018年 smallyou. All rights reserved.
//

#import "ProjectSeletedHeadView.h"
#import "ProjectSeletedModel.h"

@interface ProjectSeletedHeadView ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIButton *rowButton;
@end

@implementation ProjectSeletedHeadView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.autoresizingMask = UIViewAutoresizingNone;
    
    self.section = -1;
    
    [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewDidTap)]];
    
//    self.rowButton.app_touchExtendInset = UIEdgeInsetsMake(-20, -20, -20, -20);
//    [self.rowButton addTarget:self action:@selector(rowButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setProjectSeletedModel:(ProjectSeletedModel *)projectSeletedModel {
    _projectSeletedModel = projectSeletedModel;
    
    self.nameLabel.text = projectSeletedModel.name;
    self.rowButton.selected = projectSeletedModel.isOpen;
    NSLog(@"---> %@", projectSeletedModel.imageUrl);
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:projectSeletedModel.imageUrl] placeholderImage:[UIImage imageNamed:@"ic_common_bg_main"]];
}

- (void)viewDidTap {
    if (self.section == -1 || self.rowButton.isSelected) {
        return;
    }
    
    if ([self.delegate respondsToSelector:@selector(projectSeletedHeadView:openSection:)]) {
        [self.delegate projectSeletedHeadView:self openSection:self.section];
    }
}

/*
- (void)rowButtonDidClick {
    if (self.section == -1 || self.rowButton.isSelected) {
        return;
    }
    
    if ([self.delegate respondsToSelector:@selector(projectSeletedHeadView:openSection:)]) {
        [self.delegate projectSeletedHeadView:self openSection:self.section];
    }
}
 */

+ (CGFloat)viewHeight {
    return 60.f;
}

@end
